/* ==========================================
   KINGDOM CHOICES - PROFESSIONAL UI/UX - v2.1.0
   Design System: Medieval Fantasy Strategy Game
   Color Scheme: Purple Theme (#7C3AED primary)
   Typography: Inter (Google Fonts)
   ========================================== */

/* === ROOT & RESET === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Design System Colors */
    --color-primary: #7C3AED;
    --color-primary-dark: #6D28D9;
    --color-primary-light: #A78BFA;
    --color-secondary: #A78BFA;
    --color-cta: #F43F5E;
    --color-cta-hover: #E11D48;
    --color-bg-dark: #0F0F23;
    --color-bg-purple: #1E1B4B;
    --color-text-light: #E2E8F0;
    --color-text-muted: #94A3B8;
    --color-success: #10B981;
    --color-warning: #F59E0B;
    --color-danger: #EF4444;
    --color-gold: #FFD700;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;
    --font-size-3xl: 3rem;

    /* Transitions */
    --transition-fast: 150ms ease-out;
    --transition-base: 200ms ease-out;
    --transition-slow: 300ms ease-out;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.5);
}

html {
    overflow-x: hidden;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    color: var(--color-text-light);
    font-size: var(--font-size-base);
    line-height: 1.6;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.game-container {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 10px;
}

@media (min-width: 768px) {
    .game-container {
        padding: 15px;
    }
}

/* === ANIMATIONS === */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================
   STATS BAR
   ========================================== */
.stats-bar {
    background: rgba(15, 15, 35, 0.9);
    backdrop-filter: blur(10px);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(124, 58, 237, 0.3);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
    min-width: 140px;
}

.stat-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.stat-icon path {
    fill: var(--color-primary-light);
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 4px;
}

.stat-bar {
    height: 100%;
    transition: width var(--transition-slow), background-color var(--transition-base);
    border-radius: 10px;
    position: relative;
}

.stat-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
    border-radius: 10px;
}

.population-bar {
    background: linear-gradient(90deg, #3B82F6, #60A5FA);
}

.wealth-bar {
    background: linear-gradient(90deg, #F59E0B, #FCD34D);
}

.happiness-bar {
    background: linear-gradient(90deg, #EC4899, #F472B6);
}

.stat-value {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    font-weight: 700;
}

.turn-counter {
    background: rgba(124, 58, 237, 0.3);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 12px;
    font-weight: 700;
    color: #fff;
    border: 1px solid rgba(124, 58, 237, 0.5);
    white-space: nowrap;
    font-size: var(--font-size-sm);
}

/* ==========================================
   GAME SCREEN
   ========================================== */
.game-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: url('./throne-room.jpg') center/cover;
    background-attachment: fixed;
}

.throne-room {
    width: 100%;
    height: 100%;
    display: flex;
    gap: var(--spacing-md);
    align-items: stretch;
}

@media (max-width: 767px) {
    .throne-room {
        flex-direction: column;
    }
}

/* === KING SECTION === */
.king-section {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    overflow: hidden;
    min-height: 300px;
}

.king-character {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.king-response-container {
    position: absolute;
    top: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    max-width: 90%;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    z-index: 10;
}

.king-response-container.visible {
    opacity: 1;
    pointer-events: auto;
}

.king-response-bubble {
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(10px);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: 16px;
    border: 2px solid var(--color-primary);
    box-shadow: var(--shadow-xl);
    animation: bubbleAppear var(--transition-slow);
}

@keyframes bubbleAppear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.king-response-text {
    color: var(--color-text-light);
    font-size: var(--font-size-lg);
    font-weight: 600;
    text-align: center;
}

/* === NPC SECTION === */
.npc-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-md);
}

.npc-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    max-width: 500px;
    width: 100%;
    background: linear-gradient(180deg, #6D28D9 0%, #5B21B6 50%, #4C1D95 100%);
    border-radius: 40px;
    padding: 8px;
    box-shadow:
        0 0 0 6px #FCD34D,
        0 0 0 12px #F59E0B,
        0 20px 60px rgba(0, 0, 0, 0.6),
        inset 0 -4px 20px rgba(0, 0, 0, 0.3),
        inset 0 4px 20px rgba(255, 255, 255, 0.2);
    position: relative;
    animation: slideInFromRight 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-top: 80px;
}

/* Add this class via JavaScript when card needs to re-enter */
.npc-container.card-slide-in {
    animation: slideInFromRight 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Slide out animation for when answer is given */
.npc-container.card-slide-out {
    animation: slideOutToLeft 0.5s cubic-bezier(0.6, 0.04, 0.98, 0.34) forwards;
}

/* Card header title */
.npc-container::before {
    content: 'Royal Request';
    position: absolute;
    top: -65px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #6D28D9 0%, #5B21B6 100%);
    color: #FFF;
    font-size: 28px;
    font-weight: 900;
    padding: 16px 60px;
    border-radius: 30px;
    border: 6px solid #FCD34D;
    box-shadow:
        0 0 0 4px #F59E0B,
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 -3px 10px rgba(0, 0, 0, 0.3),
        inset 0 2px 10px rgba(255, 255, 255, 0.2);
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.6),
        0 0 10px rgba(255, 255, 255, 0.3);
    letter-spacing: 2px;
    text-transform: uppercase;
    white-space: nowrap;
    z-index: 10;
}

/* Decorative corner ornaments */
.npc-container::after {
    content: '👑';
    position: absolute;
    top: -75px;
    right: -10px;
    font-size: 40px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
    animation: crownBob 2s ease-in-out infinite;
    z-index: 11;
}

@keyframes crownBob {
    0%, 100% {
        transform: translateY(0) rotate(10deg);
    }
    50% {
        transform: translateY(-8px) rotate(15deg);
    }
}

/* Slide in from right side of screen */
@keyframes slideInFromRight {
    0% {
        opacity: 0;
        transform: translateX(150%) scale(0.8) rotate(10deg);
    }
    60% {
        opacity: 1;
        transform: translateX(-5%) scale(1.05) rotate(-2deg);
    }
    80% {
        transform: translateX(2%) scale(0.98) rotate(1deg);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1) rotate(0deg);
    }
}

/* Slide out to left side of screen */
@keyframes slideOutToLeft {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateX(-150%) scale(0.8) rotate(-15deg);
    }
}

/* Old cardEntrance - keeping for compatibility */
@keyframes cardEntrance {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-100px) rotate(-15deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.1) translateY(10px) rotate(3deg);
    }
    70% {
        transform: scale(0.95) translateY(-5px) rotate(-1deg);
    }
    85% {
        transform: scale(1.02) translateY(2px) rotate(0.5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0) rotate(0deg);
    }
}

.npc-character {
    width: 100%;
    max-width: 100%;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8rem;
    background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
    border-radius: 32px 32px 0 0;
    border: none;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.1);
}

.npc-character img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 18px;
}

.npc-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 18px;
}

.npc-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8rem;
    background: rgba(124, 58, 237, 0.1);
    border-radius: 18px;
}

.speech-bubble {
    background: linear-gradient(180deg, #5B21B6 0%, #4C1D95 100%);
    padding: 24px 28px 28px 28px;
    border-radius: 0 0 32px 32px;
    border: none;
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.npc-name {
    font-size: 24px;
    color: #FCD34D;
    font-weight: 800;
    margin-bottom: 8px;
    text-align: center;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 10px rgba(252, 211, 77, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.npc-message {
    color: #F3F4F6;
    line-height: 1.7;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    margin-bottom: 8px;
}

/* === DECISION BUTTONS === */
.decision-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 8px;
}

.decision-btn {
    flex: 1;
    max-width: 180px;
    padding: 16px 24px;
    border: none;
    border-radius: 20px;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.4),
        inset 0 -3px 10px rgba(0, 0, 0, 0.2),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.decision-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.decision-btn:hover::before {
    left: 100%;
}

.decision-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 -3px 10px rgba(0, 0, 0, 0.2),
        inset 0 2px 10px rgba(255, 255, 255, 0.4),
        0 0 20px currentColor;
}

.decision-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.decision-btn:focus-visible {
    outline: 3px solid #FCD34D;
    outline-offset: 3px;
}

.decision-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.yes-btn {
    background: linear-gradient(135deg, #10B981, #059669);
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.yes-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.yes-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.no-btn {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.no-btn:hover {
    background: linear-gradient(135deg, #DC2626, #B91C1C);
}

/* === IMPACT DISPLAY === */
.impact-display {
    position: fixed;
    z-index: 9999 !important;
    pointer-events: none;
    display: block !important;
    width: 400px;
    height: 400px;
    /* Position will be set dynamically by JavaScript */
}

.impact-item {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 24px 48px;
    border-radius: 20px;
    font-size: 56px;
    font-weight: 900;
    animation: floatUpFade 3s ease-out forwards;
    letter-spacing: 3px;
    white-space: nowrap;
    border: 4px solid;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
}

.impact-item.positive {
    color: #00FF00;
    border-color: #00FF00;
    text-shadow:
        0 0 20px #00FF00,
        0 0 40px #00FF00,
        0 4px 12px rgba(0, 0, 0, 1);
    box-shadow:
        0 0 40px rgba(0, 255, 0, 0.6),
        0 8px 32px rgba(0, 0, 0, 0.8);
}

.impact-item.negative {
    color: #FF0000;
    border-color: #FF0000;
    text-shadow:
        0 0 20px #FF0000,
        0 0 40px #FF0000,
        0 4px 12px rgba(0, 0, 0, 1);
    box-shadow:
        0 0 40px rgba(255, 0, 0, 0.6),
        0 8px 32px rgba(0, 0, 0, 0.8);
}

/* Float up and fade animation with font size growth */
@keyframes floatUpFade {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    20% {
        opacity: 1;
        transform: translateX(-50%) translateY(-50px) scale(1.1);
    }
    40% {
        opacity: 1;
        transform: translateX(-50%) translateY(-100px) scale(1.2);
    }
    60% {
        opacity: 0.9;
        transform: translateX(-50%) translateY(-150px) scale(1.3);
    }
    80% {
        opacity: 0.5;
        transform: translateX(-50%) translateY(-200px) scale(1.4);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-250px) scale(1.5);
    }
}

/* Old animations - keeping for compatibility */
@keyframes impactPop {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-15deg);
    }
    15% {
        opacity: 1;
        transform: scale(1.3) rotate(5deg);
    }
    25% {
        transform: scale(1) rotate(0deg);
    }
    75% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    90% {
        opacity: 0.5;
        transform: scale(1.2) rotate(3deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg) translateY(-50px);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    25% {
        transform: translateX(-10px) rotate(-2deg);
    }
    75% {
        transform: translateX(10px) rotate(2deg);
    }
}

/* Simple float up animation for impacts */
@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-300px) scale(1.8);
    }
}

/* ==========================================
   GAME OVER & VICTORY SCREENS
   ========================================== */
.game-over-screen,
.victory-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    animation: fadeIn var(--transition-slow);
}

.game-over-screen.active,
.game-over-screen.show,
.victory-screen.active,
.victory-screen.show {
    display: flex;
}

.game-over-content,
.victory-content {
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(20px);
    padding: var(--spacing-xl);
    border-radius: 16px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp var(--transition-slow);
}

.game-over-content h1,
.victory-content h1 {
    font-size: var(--font-size-2xl);
    color: #fff;
    margin-bottom: var(--spacing-md);
    font-weight: 700;
}

.game-over-content h1 {
    color: #EF4444;
}

.victory-content h1 {
    color: #10B981;
}

.game-over-content p,
.victory-content p {
    font-size: var(--font-size-base);
    color: var(--color-text-light);
    margin-bottom: var(--spacing-md);
    line-height: 1.5;
}

.final-stats {
    background: rgba(255, 255, 255, 0.05);
    padding: var(--spacing-md);
    border-radius: 12px;
    margin-bottom: var(--spacing-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.final-stats div {
    font-size: var(--font-size-base);
    color: var(--color-text-light);
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
}

.final-stats div:last-child {
    margin-bottom: 0;
}

.restart-btn {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-primary);
    border: none;
    border-radius: 8px;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.restart-btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
}

.restart-btn:active {
    transform: translateY(0);
}

.restart-btn:focus-visible {
    outline: 2px solid var(--color-primary-light);
    outline-offset: 2px;
}

/* ==========================================
   MUSIC TOGGLE
   ========================================== */
.music-toggle {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(167, 139, 250, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-lg);
}

.music-toggle:hover {
    transform: scale(1.1);
    background: rgba(124, 58, 237, 1);
    box-shadow: var(--shadow-glow);
}

.music-toggle:active {
    transform: scale(0.95);
}

.music-toggle:focus-visible {
    outline: 3px solid var(--color-primary-light);
    outline-offset: 4px;
}

.music-icon-muted,
.music-icon-playing {
    width: 28px;
    height: 28px;
    color: #fff;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

/* Mobile Portrait (320px - 479px) */
@media (max-width: 479px) {
    :root {
        --font-size-3xl: 1.75rem;
        --font-size-2xl: 1.25rem;
        --font-size-xl: 1.125rem;
        --spacing-lg: 1.5rem;
        --spacing-xl: 2rem;
    }

    .stats-bar {
        padding: var(--spacing-sm);
        gap: var(--spacing-sm);
    }

    .throne-room {
        gap: var(--spacing-sm);
    }

    .king-section,
    .npc-section {
        padding: var(--spacing-sm);
        min-height: 200px;
    }

    .npc-character {
        max-width: 150px;
        height: 150px;
    }

    .speech-bubble {
        padding: var(--spacing-md);
    }

    .decision-btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-base);
    }

    .music-toggle {
        width: 48px;
        height: 48px;
        bottom: var(--spacing-md);
        right: var(--spacing-md);
    }

    .music-icon-muted,
    .music-icon-playing {
        width: 24px;
        height: 24px;
    }
}

/* Mobile Landscape & Small Tablets (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .npc-character {
        max-width: 180px;
        height: 180px;
    }
}

/* All Mobile Devices (up to 767px) */
@media (max-width: 767px) {
    .stats-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .stat-item {
        min-width: 100%;
    }

    .throne-room {
        flex-direction: column;
    }

    .decision-buttons {
        flex-direction: column;
    }

    .decision-btn {
        max-width: 100%;
    }

    .king-response-container {
        max-width: 95%;
    }

    .game-over-content,
    .victory-content {
        padding: var(--spacing-lg);
    }
}

/* Tablets Portrait (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .npc-character {
        max-width: 220px;
        height: 220px;
    }

    .throne-room {
        flex-direction: row;
    }

    .decision-buttons {
        flex-direction: row;
    }
}

/* Desktop & Tablets Landscape (1024px - 1439px) */
@media (min-width: 1024px) and (max-width: 1439px) {
    .npc-character {
        max-width: 260px;
        height: 260px;
    }
}

/* Large Desktop (1440px - 1919px) */
@media (min-width: 1440px) and (max-width: 1919px) {
    .npc-character {
        max-width: 300px;
        height: 300px;
    }

    .throne-room {
        gap: var(--spacing-xl);
    }
}

/* Ultra-wide & 4K (1920px+) */
@media (min-width: 1920px) {
    .npc-character {
        max-width: 350px;
        height: 350px;
    }

    .throne-room {
        gap: var(--spacing-xl);
        max-width: 1800px;
        margin: 0 auto;
    }

    .speech-bubble {
        padding: var(--spacing-xl);
    }

    .decision-btn {
        max-width: 250px;
    }
}

/* Landscape Orientation Specific */
@media (orientation: landscape) and (max-height: 600px) {
    .throne-room {
        flex-direction: row;
    }

    .stats-bar {
        flex-direction: row;
        flex-wrap: nowrap;
        padding: var(--spacing-sm);
    }

    .stat-item {
        min-width: auto;
    }

    .king-section,
    .npc-section {
        min-height: auto;
    }
}

/* Portrait Orientation */
@media (orientation: portrait) and (max-width: 767px) {
    .throne-room {
        flex-direction: column;
    }
}

/* Tablet & Desktop Portrait */
@media (orientation: portrait) and (min-width: 768px) {
    .throne-room {
        flex-direction: column;
    }
}

/* Small Height Devices - Compact Mode */
@media (max-height: 700px) {
    :root {
        --spacing-lg: 1.25rem;
        --spacing-xl: 2rem;
    }

    .king-section,
    .npc-section {
        min-height: 250px;
    }
}

/* Very Small Height - Ultra Compact */
@media (max-height: 500px) and (orientation: landscape) {
    .stats-bar {
        padding: 8px 12px;
    }

    .throne-room {
        gap: 12px;
    }

    .npc-character {
        max-width: 180px;
        height: 180px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .decision-btn {
        min-height: 48px;
        padding: var(--spacing-md) var(--spacing-lg);
    }

    .music-toggle {
        width: 56px;
        height: 56px;
    }

    /* Better tap feedback */
    .decision-btn:active {
        transform: scale(0.95);
    }
}

/* High DPI Displays (Retina) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure SVG icons render crisply */
    svg {
        shape-rendering: geometricPrecision;
    }

    /* Enhance text rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Print Styles */
@media print {
    .music-toggle,
    .decision-buttons {
        display: none !important;
    }

    .game-container {
        background: white;
    }

    .stats-bar,
    .throne-room {
        border: 1px solid #ccc;
    }
}

/* Accessibility - High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --color-bg-dark: #000000;
        --color-text-light: #FFFFFF;
        --color-primary: #9F7AEA;
        --color-cta: #FC8181;
    }

    .stats-bar,
    .king-section,
    .npc-section,
    .speech-bubble {
        border: 2px solid #FFFFFF;
    }

    .decision-btn,
    .restart-btn {
        border: 2px solid #FFFFFF;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    /* Already dark by default, but ensure consistency */
    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }
}

/* Light Mode Override (if user prefers light) */
@media (prefers-color-scheme: light) {
    /* Keep dark theme for game atmosphere */
    /* No changes - game is designed to be dark */
}

/* Foldable Devices - Dual Screen Support */
@media (spanning: single-fold-vertical) {
    .throne-room {
        flex-direction: row;
        gap: var(--spacing-xl);
    }

    .king-section {
        margin-right: env(fold-right);
    }
}

@media (spanning: single-fold-horizontal) {
    .throne-room {
        flex-direction: column;
        gap: var(--spacing-lg);
    }

    .stats-bar {
        margin-bottom: env(fold-bottom);
    }
}
